abstract class Component {
    public abstract String show();
}

class ProductA extends Component {
    @Override
    public String show() {
        return "ProductA";
    }
}

public abstract class Decorator extends Component {
    public static void main(String[] args) {
        Component pa = new ProductA();

        Decorator da = new DecoratorA();
        Decorator db = new DecoratorB();

        System.out.println(pa.show());

        da.decorate(pa);
        System.out.println(da.show());

        db.decorate(da);
        System.out.println(db.show());
    }

    protected Component decorated = null;

    public void decorate(Component c) {
        this.decorated = c;
    }
}

class DecoratorA extends Decorator {
    @Override
    public String show() {
        return decorated.show() + " By DecoratorA";
    }
}

class DecoratorB extends Decorator {
    @Override
    public String show() {
        return decorated.show() + " By DecoratorB";
    }
}